#ifndef _SPI_CONTRLLER_H_
#define _SPI_CONTROLLER_H_

#include "types.h"

#define SPI0  0x01C41000
#define SPI1  0x01F0E000

#define SPI_GCR0(base)                       *((volatile uint32_t *)(base + 0x00))
#define SPI_GCR1(base)                       *((volatile uint32_t *)(base + 0x04))
#define SPI_INT0(base)                       *((volatile uint32_t *)(base + 0x08))
#define SPI_LVL(base)                       *((volatile uint32_t *)(base + 0x0c))
#define SPI_FLG(base)                       *((volatile uint32_t *)(base + 0x10))
#define SPI_PC0(base)                       *((volatile uint32_t *)(base + 0x14))
#define SPI_PC1(base)                       *((volatile uint32_t *)(base + 0x18))
#define SPI_PC2(base)                       *((volatile uint32_t *)(base + 0x1c))
#define SPI_PC3(base)                       *((volatile uint32_t *)(base + 0x20))
#define SPI_PC4(base)                       *((volatile uint32_t *)(base + 0x24))
#define SPI_PC5(base)                       *((volatile uint32_t *)(base + 0x28))
#define SPI_RES1(base)                       *((volatile uint32_t *)(base + 0x2c))
#define SPI_RES2(base)                       *((volatile uint32_t *)(base + 0x30))
#define SPI_RES3(base)                       *((volatile uint32_t *)(base + 0x34))
#define SPI_DAT0(base)                       *((volatile uint32_t *)(base + 0x38))
#define SPI_DAT1(base)                       *((volatile uint32_t *)(base + 0x3c))
#define SPI_BUF(base)                       *((volatile uint32_t *)(base + 0x40))
#define SPI_EMU(base)                       *((volatile uint32_t *)(base + 0x44))
#define SPI_DELAY(base)                      *((volatile uint32_t *)(base + 0x48))
#define SPI_DEF(base)                       *((volatile uint32_t *)(base + 0x4c))
#define SPI_FMT0(base)                       *((volatile uint32_t *)(base + 0x50))
#define SPI_FMT1(base)                       *((volatile uint32_t *)(base + 0x54))
#define SPI_FMT2(base)                       *((volatile uint32_t *)(base + 0x58))
#define SPI_FMT3(base)                       *((volatile uint32_t *)(base + 0x5c))
#define SPI_VEC0(base)                       *((volatile uint32_t *)(base + 0x60))
#define SPI_VEC1(base)                       *((volatile uint32_t *)(base + 0x64))

#define SPI_DAT1_0(base)                     *((volatile uint8_t *)(base + 0x3c))
#define SPI_DAT1_1(base)                     *((volatile uint8_t *)(base + 0x3d))
#define SPI_DAT1_2(base)                     *((volatile uint8_t *)(base + 0x3e))
#define SPI_DAT1_3(base)                     *((volatile uint8_t *)(base + 0x3f))

#endif
